import { useState } from "react";
import ChildComp1 from "./ChildComp1";
import ChildComp2 from "./ChildComp2";
import withLog from "./WithLog";
const ChildComp1WithLog = withLog(ChildComp1);
const ChildComp2WithLog = withLog(ChildComp2);

export default function HocTest() {
  const [visible, setVisible] = useState(false);
  return (
    <div>
      {/* <ChildComp1 name="ywp"></ChildComp1>
      <ChildComp2 age="22"></ChildComp2> */}
      {visible ? (
        <ChildComp1WithLog name="ywp" />
      ) : (
        <ChildComp2WithLog age="22" />
      )}

      <button onClick={() => setVisible(!visible)}>切换组件</button>
    </div>
  );
}
